package edu.xidian.onlinedocument.utils.ot.internal.operations;

import edu.xidian.onlinedocument.utils.ot.internal.Text;
import org.apache.commons.lang3.CharSequenceUtils;

import java.nio.charset.StandardCharsets;

public class Insert extends Change {
    /**
     * 从当前位置开始向后插入content内容的文本
     */
    private String content;

    public Insert(String content) {
        this.content = content;
    }

    /*
    @Override
    public Text apply(int position, Text text) {
        return null;
    }
     */

    @Override
    public Integer offset() {
        return content.length();
    }

    @Override
    public String toString() {
        return "{ insert:\"" + (new String(content))
                .replace("\n", "\\n")
                .replace("\t", "\\t")+ "\" }";
    }

    @Override
    public String value() {
        return content;
    }
}
